@layout("../../system/layout.html", {title: "数据权限-角色管理"}){
<ul id="orgTree" class="ztree"></ul>
<script type="text/javascript">
    var setting = {
        data: {
            simpleData: {
                enable: true,
                idKey: "orgId",
                pIdKey: "parentId",
                rootPId: 0
            },
            key: {
                url: "nourl"
            }
        },
        check: {
            enable: true,
            nocheckInherit: true,
            chkboxType: {"Y": "", "N": ""}
        }
    };
    var ztree;

    var vm = new Vue({
        el: '#dpLTE',
        data: {
            role: {}
        },
        methods: {
            getOrg: function (menuId) {
                $.ajax({
                    type: 'get',
                    async: false,
                    contentType: 'application/json',
                    url: '../../sys/org/list?_' + $.now(),
                    data: null,
                    success: function (r) {
                        ztree = $.fn.zTree
                            .init($("#orgTree"), setting, r);
                        ztree.expandAll(true);
                    },
                    dataType: 'json'
                });
            },
            setForm: function () {
                this.getOrg();
                $.SetForm({
                    url: '../../sys/role/info',
                    param: vm.role.roleId,
                    success: function (data) {
                        vm.role = data;
                        //勾选角色所拥有的数据权限
                        var orgIds = vm.role.orgIdList;
                        for (var i = 0; i < orgIds.length; i++) {
                            var node = ztree.getNodeByParam("orgId", orgIds[i]);
                            ztree.checkNode(node, true, false);
                        }
                    }
                });
            },
            acceptClick: function () {
                var nodes = ztree.getCheckedNodes(true);
                var orgIdList = new Array();
                for (var i = 0; i < nodes.length; i++) {
                    orgIdList.push(nodes[i].orgId);
                }
                vm.role.orgIdList = orgIdList;
                $.ConfirmForm({
                    url: '../../sys/role/authorize/data?_' + $.now(),
                    param: vm.role,
                    success: function (data) {

                    }
                });
            }
        }
    })
</script>
@}